package com.lsu.app.mapper;

import com.lsu.app.bean.StudyLog;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 *
 * @description 针对表【study_log(学习记录)】的数据库操作Mapper
 * @Date 2023-11-07 18:27:02
 * @author hjj
 */
@Mapper
public interface StudyLogMapper extends BaseMapper<StudyLog> {
        @Select("select create_time from study_log where id =#{id}")
        String getTimeStringById(Integer id);//获取时间字符串
        @Select("select * from study_log where state = 1 and user_id=#{userId} and end_time>=#{dateTime} and (course_id,end_time)in(select course_id,MAX(end_time) from study_log where user_id = #{userId} group by course_id) order by end_time desc")
        List<StudyLog> getStudyLogByUserId(@Param("userId") Integer userId, @Param("dateTime") String dateTime);//获取日期最新的课程日志
}




